/*
 * Copyright (c) Extreme Vision Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef TRT_COMMON_H
#define TRT_COMMON_H

#include<map>
#include "evdeploy/runtime/trt/trt_base.h"

namespace ev
{

class TrtModel: public EVBaseTrtModel, public EVTrtModel
{
    public:        
        TrtModel();

        ~TrtModel();        
        //init model and infos
        EVStatus Init(const char* net, void** config) override;

        EVStatus UnInit() override;
        //run inference
        EVStatus Infer(EVModelData* in, EVModelData* out) override; 

        EVStatus SetIO(const std::vector<std::string>& inputs, const std::vector<std::string>& outputs) override;
        
        EVStatus OptimizeModel(const char* model_name) override;    
        
    private:             
        std::vector<std::string> m_input_names;
        std::vector<std::string> m_output_names;
        std::map<std::string, int> m_name_2_index;
        std::map<std::string, Dims> m_name_2_dims;
        std::map<std::string, int> m_name_2_size;
        std::map<std::string, void*> m_name_2_host_buffer;
        std::map<std::string, void*> m_name_2_gpu_buffer;
};

}//namespace ev

#endif 